#!/usr/bin/env python
# -*- encoding: utf-8 -*-
# Project: spd-sxmcc
"""
@author: lyndon
@time Created on 2019/3/6 18:23
@desc
"""

import json
from six import iteritems


orgi_data = """
{
    "chinaxinge": {
        "all": {
            "pending": 2,
            "success": 77
        },
        "paused": null
    },
    "fangtianxia_ty_rsf": {
        "all": {
            "failed": 11,
            "pending": 22,
            "success": 20
        },
        "paused": null
    },
    "fangtianxiatest": {
        "all": {
            "pending": 99,
            "success": 40
        },
        "paused": null
    },
    "ifeve": {
        "1d": {
            "pending": 28,
            "success": 27
        },
        "all": {
            "success": 87
        },
        "paused": null
    },
    "imdbtest": {
        "all": {
            "failed": 10,
            "success": 351
        },
        "paused": null
    },
    "jianshu": {
        "1d": {
            "pending": 2,
            "retry": 2,
            "success": 1
        },
        "all": {
            "pending": 1,
            "success": 1
        },
        "paused": null
    },
    "renren": {
        "1d": {
            "pending": 2,
            "retry": 2,
            "success": 1
        },
        "all": {
            "pending": 2,
            "success": 41
        },
        "paused": null
    },
    "sxyd1": {
        "1d": {
            "pending": 626,
            "success": 223
        },
        "1h": {
            "pending": 415,
            "success": 92
        },
        "all": {
            "success": 223
        },
        "paused": null
    },
    "taonandianduchangsushe": {
        "all": {
            "success": 46
        },
        "paused": null
    },
    "teradata": {
        "all": {
            "failed": 4,
            "pending": 1,
            "success": 76
        },
        "paused": null
    },
    "teradata_test": {
        "all": {
            "pending": 6,
            "success": 69
        },
        "paused": null
    },
    "tjttk": {
        "all": {
            "pending": 1,
            "success": 1
        },
        "paused": null
    },
    "woi5j_ty_rsf": {
        "paused": null
    },
    "woiwoj_ty_rsf": {
        "all": {
            "pending": 28,
            "success": 19
        },
        "paused": null
    }
}
"""

data = json.loads(orgi_data)
print(data)

# for type, counters in iteritems(data):
#     print(type, counters)
result = {}
for type, counters in iteritems(data):
    for project, counter in iteritems(counters):
        result.setdefault(project, {})[type] = counter

print(result)